#ifndef __PROTOCAL_H__
#define __PROTOCAL_H__

#include "protocal_define.h"
#include "radar.h"
#include "respond_struct_define.h"
#include <iostream>

class Protocal {

  public:
    Protocal(uint8_t, Radar *, SystemParameters *);
    ~Protocal();

  public:
    void process_msg(const uint8_t *buffer, int len);
    void ProcessHeartbeat(void);
    void sendSignalTable();
    void ProcessGetSignalTable(const uint8_t *buffer, int len);
    void ProcessSetPayloadParameter(const uint8_t *buffer, int len);
    void ProcessUavFlightCtrl(const uint8_t *buffer, int len);
    void ProcessRemotePoweroff(const uint8_t *buffer, int len);
    void ProcessFlightCtrlParameter(const uint8_t *buffer, int len);
    void ProcessPayloadCtrl(const uint8_t *buffer, int len);
    void ProcessGetUAVStatus(const uint8_t *buffer, int len);
    void ProcessGetPayloadStatus(const uint8_t *buffer, int len);
    void ProcessPositionMidFreq(const uint8_t *buffer, int len);
    void ProcessDataRemove(const uint8_t *buffer, int len);
    void ProcessTargetPosition(const uint8_t *buffer, int len);
    void ProcessTargetLoadSimulateData(const uint8_t *buffer, int len);
    void set_send_callback(const std::function<int(const uint8_t *, int)> callback);

    void SendIQ2Computer(signaltable_t *signaltable);

  private:
    void SendResponse(uint8_t cmd);
    void RemoveMidData(dataremovecmd_t *cmd);
    void GetSignalTable(dataremovecmd_t *cmd);

    std::function<int(const uint8_t *, int)> _send_callback;
    uint8_t _device_type;
    uint8_t _last_ip_octet;
    SystemParameters *system_parameters;
    Radar *m_radar;
};

#endif // #ifndef __PROTOCAL_H__
